﻿
namespace Sai.Core
{
	using System.Xml.Serialization;
	using Sai.Core.Introspection;
	using System.Text;
    using System;
	
	[Obsolete("Not used")]
	public class TypeTaxonomyChange : IDiscoveredTypeChange
	{
		public TypeTaxonomyChange()
		{
		}

		public TypeTaxonomyChange(TypeName type, TypeTaxonomy from, TypeTaxonomy to)
		{
			this.Type = type.FullName.ToString();
			this.From = from.ToString();
			this.To = to.ToString();
            this.Reason = TypeChangeReason.TypeTaxonomy;
		}

		// embed xslt xml tags for our own dsl.
		// <code>
		[XmlAttribute("Type")]
		public string Type { get; set; }

		[XmlAttribute("From")]
		public string From { get; set; }

		[XmlAttribute("To")]
		public string To { get; set; }

        public TypeChangeReason Reason { get; set; }

        /// <summary>
        /// .Net code representation of change.
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// Plain language representation of change.
        /// </summary>
        public string Message { get; set; }

		public string ToXml()
		{
			StringBuilder builder = new StringBuilder();

//            <xsl:if test="not(@To = '')">
//    <tr><td>Base type changed from <code><xsl:value-of select="@From" /></code> to <code><xsl:value-of select="@To" /></code></td></tr>
//</xsl:if>

//<xsl:if test="@To = ''">
//    <tr><td>No longer derived from <code><xsl:value-of select="@From" /></code></td></tr>
//</xsl:if>

			return builder.ToString();
		}

		public override string ToString()
		{
			return string.Format("{0} has changed from {1} to {2}", this.Type, this.From, this.To);
		}
	}
}
